<!DOCTYPE html>
<html>

<head lang="en">
    <meta charset="UTF-8">
    <title>动态组件</title>
    <script src="../vue.js"></script>
    <script src="../vue-router.js"></script>
</head>

<body>
    <div id="app">
        <component :is="currentView"></component>
    </div>
    <script>
        //在子组件中，只需将数据传递到插槽，就像你将 prop 传递给组件一样：
        Vue.component('first', {
            template: '<div class="child"><slot text="我是来自子组件的"></slot></div>'

        })
        var app = new Vue({
            el: '#app',
            data() {
                return {
                    currentView: 'home'
                }
            },
            components: {
                home: {template:'<div>home</div>'},
                posts: { template:'<div>posts</div>' },
                archive: {template:'<div>archive</div>'}
            }
        })
    </script>
</body>

</html>